/* 
 * File:   v4l_interface.h
 * Author: gustavo
 *
 * Created on December 26, 2011, 2:57 AM
 */

#ifndef V4L_INTERFACE_H
#define	V4L_INTERFACE_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <gtk/gtk.h>

#include <v4l/v4l.h>
#include <util/list.h>

#define TYPE_V4L_INTERFACE             (v4l_interface_get_type ())
#define V4L_INTERFACE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_V4L_INTERFACE, v4lInterface))
#define V4L_INTERFACE_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), TYPE_V4L_INTERFACE, v4lInterfaceClass))
#define IS_V4L_INTERFACE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_V4L_INTERFACE))
#define IS_V4L_INTERFACE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), TYPE_V4L_INTERFACE))
#define V4L_INTERFACE_GET_CLASS(inst)  (G_TYPE_INSTANCE_GET_CLASS ((inst), TYPE_V4L_INTERFACE, v4lInterfaceClass))

	typedef struct _v4l_interface v4lInterface;
	typedef struct _v4l_interface_class v4lInterfaceClass;
	typedef enum _v4l_signal v4lSignal;

	enum _v4l_signal {
		V4L_SIGNAL_OPEN_DEVICE = 0,
		V4L_SIGNAL_CLOSE_DEVICE,
		V4L_SIGNAL_START_DEVICE,
		V4L_SIGNAL_STOP_DEVICE,
		V4L_NUMBER_OF_SIGNALS
	};

	struct _v4l_interface {
		GtkVBox parent;
		gboolean started;

		//======================================================================
		//ImpVideoDevice * vd;
		struct v4l_driver v4ldrv;
		//struct v4l_buffers v4lbuffers;

		//======================================================================
		GtkComboBox * cb_device;
		GtkListStore * ls_device;
		GtkCellRenderer * re_device;
		List * l_device;

		//======================================================================
		GtkButton * bt_start;

		//======================================================================
		GtkLabel * lb_device_name;
		GtkLabel * lb_device_card;
		GtkLabel * lb_device_driver;
		GtkLabel * lb_device_bus;

		//======================================================================
		GtkSpinButton * sp_width;
		GtkSpinButton * sp_height;

		//======================================================================
		GtkComboBox * cb_v4l2_frmint;
		GtkListStore * ls_v4l2_frmint;
		GtkCellRenderer * re_v4l2_frmint;

		//======================================================================
		GtkComboBox * cb_v4l2_input;
		GtkComboBox * cb_v4l2_standard;
		GtkComboBox * cb_v4l2_format;
		GtkComboBox * cb_v4l2_frmsize;
		//----------------------------------
		GtkListStore * ls_v4l2_input;
		GtkListStore * ls_v4l2_standard;
		GtkListStore * ls_v4l2_format;
		GtkListStore * ls_v4l2_frmsize;
		//----------------------------------
		GtkCellRenderer * re_v4l2_input;
		GtkCellRenderer * re_v4l2_standard;
		GtkCellRenderer * re_v4l2_format;
		GtkCellRenderer * re_v4l2_frmsize;
		//----------------------------------
		
		
		GtkNotebook * notebook;
		List * l_ctrl_widgets;
		List * l_ctrl;
		
		//----------------------------------
		List * l_v4l2_input;
		List * l_v4l2_standard;
		List * l_v4l2_format;
		List * l_v4l2_frmsize;
	};

	struct _v4l_interface_class {
		GtkVBoxClass parent_class;

		void (*v4l_start_device) (v4lInterface * v4li);
		void (*v4l_stop_device) (v4lInterface * v4li);

	};

	GType v4l_interface_get_type(void);
	GtkWidget* v4l_interface_new(void);
	
	void * v4l_interface_grab_gray(v4lInterface * v4li, char * gray);
	void * v4l_interface_grab_rgb(v4lInterface * v4li, char * rgb);

#ifdef	__cplusplus
}
#endif

#endif	/* V4L_INTERFACE_H */

